Join our webinar on Wednesday, June 26, at 1pm EDTHow Chia Mitigates Risk in the Crypto Industry.Register
Socket
Socket
Sign inDemoInstall

vue-class-component

Package Overview
Dependencies
21
Maintainers
2
Versions
48
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    vue-class-component

ES201X/TypeScript class decorator for Vue components


Version published
Weekly downloads
406K
decreased by-3.96%
Maintainers
2
Install size
73.5 kB
Created
Weekly downloads
 

Package description

What is vue-class-component?

The vue-class-component package is a library that allows you to define Vue components using ES2015/ES6 class syntax. It provides a more structured and object-oriented approach to building Vue components, making it easier to manage and maintain complex applications.

What are vue-class-component's main functionalities?

Class-based Component Definition

This feature allows you to define Vue components using ES6 class syntax. The @Component decorator is used to mark a class as a Vue component.

import { Vue, Component } from 'vue-class-component';

@Component
class MyComponent extends Vue {
  message: string = 'Hello, world!';

  greet() {
    console.log(this.message);
  }
}

Lifecycle Hooks

You can define lifecycle hooks as methods within the class. This example shows how to use the created lifecycle hook.

import { Vue, Component } from 'vue-class-component';

@Component
class MyComponent extends Vue {
  created() {
    console.log('Component created');
  }
}

Computed Properties

Computed properties can be defined as getter methods within the class. This example demonstrates a computed property that concatenates first and last names.

import { Vue, Component } from 'vue-class-component';

@Component
class MyComponent extends Vue {
  firstName: string = 'John';
  lastName: string = 'Doe';

  get fullName() {
    return `${this.firstName} ${this.lastName}`;
  }
}

Watchers

Watchers can be defined using the @Watch decorator. This example shows how to watch for changes to the 'message' property.

import { Vue, Component, Watch } from 'vue-class-component';

@Component
class MyComponent extends Vue {
  message: string = 'Hello';

  @Watch('message')
  onMessageChanged(newValue: string, oldValue: string) {
    console.log(`Message changed from ${oldValue} to ${newValue}`);
  }
}

Other packages similar to vue-class-component

Readme

Source

Vue Class Component v8

The next Vue Class Component for Vue v3.

Status

Beta

Documentation

The documentation is not ready yet. But you can see v8 proposals in the issue list.

Questions

For questions and support please use the the official forum or community chat. The issue list of this repo is exclusively for bug reports and feature requests.

License

MIT

Keywords

FAQs

Last updated on 20 Nov 2020

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc